<template>
    <view class="content">
        <!--单据 -->
        <projectBillsTow
            ref="billsListBox"
            @setBillsThree="setBillsThree"
            v-show="curPage == 16 && page_i == 1"
        ></projectBillsTow>
        <porjectBillsThree
            ref="getBillsInfo"
            v-show="curPage == 16 && page_i == 1"
            @addNewCustom="addNewCustom"
            @changeYunBillPrice="changeYunBillPrice"
        ></porjectBillsThree>
        <!-- 预约单 -->
        <appointmentAdd
            ref="appointmentAdd"
            v-show="page_i == 3"
            @backFun="backFun"
            :page_i="page_i"
        ></appointmentAdd>
    </view>
</template>

<script>
import projectBillsTow from "../../components/project-order/ProjectBillsTow.vue";
import porjectBillsThree from "../../components/project-order/PorjectBillsThree.vue";
import appointmentAdd from "@/components/appointment/appointmentAdd.vue";

import cmd from "../../js/Cmd.js";
import lang from "../../js/conf/Lang.js";
import minMaxClose from "../../components/min-max-close.vue";
import staticConst from "../../js/const/StaticConst.js";

import eventCtrl from "../../js/event/EventCtrl.js";

import customCtrl from "../../js/custom/CustomCtrl.js";
export default {
    components: {
        projectBillsTow,
        porjectBillsThree,
        appointmentAdd,
    },
    data() {
        return {
            curPage: staticConst.YY_DJ,
            page_i: "1",
            tab_type: "",
        };
    },
    onLoad(option) {
        this.tab_type = option.tab;
    },
    onShow() {
        this.addEvent();
    },
    onReady() {
        this.$refs.billsListBox.initData();
        if (this.tab_type) {
            this.$refs.billsListBox.pageDefaultTab(this.tab_type);
        }
    },

    methods: {
        pageDefaultTab() {},
        /********/
        backFun() {
            this.page_i = "1";
        },
        setTobookFun(data) {
            this.page_i = "3";
            this.$refs.appointmentAdd.orderModificationFun(data.orderInfos);
        },
        addEvent() {
            uni.$on(eventCtrl.COPY_RETURN_EDIT_EVENT, this.actHandler);
            uni.$on(eventCtrl.COPY_RETURN_TOBOOK, this.setTobookFun);
        },

        actHandler(data) {
			console.log('吴少辉调试')
            this.curPage = data.code;
            if (data.act == 4 || data.act == 1 || data.act == 2) {
                uni.navigateTo({
                    url: `/pages/appointmentBilling/index`,
                });
            }
        },

        /***第三页单据应该展示的数据为**/
        setBillsThree(res) {
            this.$refs.getBillsInfo.createdOrderInfo(res);
        },

        /***添加新的客户***/
        addNewCustom() {
            customCtrl.addCustomer = 1;
            this.$refs.changeTab.addNewCustom();
        },

        /****修改云单价格，更新单据列表***/
        changeYunBillPrice(data) {
            this.$refs.billsListBox.changeYunBillPrice(data);
        },
    },
};
</script>
<style lang="scss">
.content {
    display: flex;
    justify-content: flex-start;
    min-width: 820px;
    height: 100%;
    position: relative;
}
</style>